package com.espirit.init.biz;

import org.springframework.stereotype.Component;

import com.espirit.eap.manager.ModelBuilderSupport;
import com.espirit.eap.pagelayout.Element;
import com.espirit.eap.pagelayout.ModelField;
import com.espirit.hr.HrSetting;

@Component
public class HrSettingBuilder extends ModelBuilderSupport {
	static final String DEPARTMENT = "schedualDeptIds";
	
	@Override
	public boolean init() {
		return super.setClass(HrSetting.class, "OperationSetting", "运营设置");
	}	

	@Override
	public void buildFields() {
		super.buildFields();
		addModelField(DEPARTMENT, "Department", "排班部门");
	}
	
	@Override
	protected void setDefaultLayoutButtons() {
		super.setDefaultLayoutButtons();
	}
	
	@Override
	protected void addSearchFields() {
	}
	
	@Override
	protected void addListFields() {
	}
	
	@Override
	protected void addDetailFields() {
		addDetailField(convertPropertyToField( DEPARTMENT));
	}
	
	@Override
	protected Element convertFieldToElement(ModelField mf, boolean isListLayout) {
		Element element = super.convertFieldToElement(mf, isListLayout);
		String name = element.getName();
		if (DEPARTMENT.equals(name)){
			setElementTreebox(element, "fn.service('espirit.eap.manager.department').allDepartments");
		}
		return element;
	}
	
	@Override
	protected void gatherExproperties() {
		exProperties.put(REQUIRED, new String[]{DEPARTMENT});
	}
	
}
